package htlgkr.nodlehs;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class NodlehsDatabase extends SQLiteOpenHelper {

	private static String DB_NAME = "timetable.db";
	Context context;

	public NodlehsDatabase(Context context) {

		super(context, DB_NAME, null, 2);
		this.context = context;
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		
		Log.i("Database","onCreate");
		db.execSQL(DBTeacherTbl.SQL_CREATE);
		db.execSQL(DBSubjectTbl.SQL_CREATE);
		db.execSQL(DBRoomsTbl.SQL_CREATE);
		db.execSQL(DBRefSubTeaTbl.SQL_CREATE);
		db.execSQL(DBUnitTbl.SQL_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		
		Log.i("Database","onUpgrade");	
		db.execSQL(DBTeacherTbl.SQL_DROP);
		db.execSQL(DBSubjectTbl.SQL_DROP);
		db.execSQL(DBRoomsTbl.SQL_DROP);
		db.execSQL(DBRefSubTeaTbl.SQL_DROP);
		db.execSQL(DBUnitTbl.SQL_DROP);
		onCreate(db);
	}
}
